<template>
	<view id="ticketInfo">
		<view class="uni-center">
			<web-view :src="path" style="height: calc(100vh - 84px);"></web-view>
		</view>
		<view class="Button">
			<button class="mini-btn" type="default" @click="authorize('open')" size="mini">不一致</button>
			<button class="mini-btn" type="primary" @click="toPath(true, '')" size="mini">一致</button>
		</view>
		<!-- <uni-popup ref="sampleAuthorizePopup" background-color="#fff" :mask-click="false" type="dialog">
			<uni-popup-dialog title="质量检测报告核验" type="input" :duration="2000" @confirm="toPath(false)">
				<view class="Remark"><uni-easyinput type="textarea" v-model="desc" focus placeholder="请输入不一致原因"></uni-easyinput></view>
			</uni-popup-dialog>
		</uni-popup> -->
	</view>
</template>

<script>
import { reportCheck } from '@/api/qualityReport/index';

export default {
	data() {
		return {
			id: '',
			path: '',
			desc: '',
			whether: false
		};
	},
	onLoad(params) {
		this.id = params.id;
		if (plus.os.name == 'Android') {
			console.log(params.path)
			this.path = `/hybrid/html/pdf.html?url=${params.path}`
		} else {
			this.path = params.path
		}
		uni.getSystemInfo({
			success: sysinfo => {
				let height = 0
				if (plus.os.name == 'Android') {
					height = sysinfo.windowHeight - 84;
				} else {
					height = sysinfo.windowHeight - 200;
				}
				let curWindow = this.$scope.$getAppWebview();
				setTimeout(() => {
					let wv = curWindow.children()[0];
					wv.setStyle({ height: height });
					setTimeout(() => {
						uni.setNavigationBarTitle({
							title: '质量检测报告核验'
						});
					}, 200);
				}, 200);
			}
		});
	},
	methods: {
		authorize(flag, item) {
			uni.navigateTo({
				url: '/pages/qualityReport/popup/popup'
			})
		},
		toPath(bol, desc) {
			let data = {
				result: bol,
				desc: desc
			};
			reportCheck(this.id, data).then(res => {
				if (res.code == 200) {
					uni.showToast({
						title: '核验成功'
					});
					setTimeout(() => {
						let pages = getCurrentPages();
						let prevPage = pages[pages.length - 2]; //上一个页面
						prevPage.$vm.listData = [];
						prevPage.$vm.getList();
						uni.navigateBack();
					}, 1500);
				}
			});
		}
	}
};
</script>

<style>
#ticketInfo {
	min-height: 100vh;
	background-color: #fafafa;
}
.uni-center {
	width: 100vw;
	overflow: hidden;
	height: calc(100vh - 84px);
}
.Button {
	display: flex;
	margin-top: 5px;
}
.Remark {
	width: 100%;
	display: flex;
	margin-top: 10px;
}
</style>
